home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / cyberavi / txt / cyberavi.mod next >
Text File  |  1999-02-08  |  35KB  |  1,104 lines

  1. MODULE  CyberAVI;
  2.  
  3. (* $IFNOT DEBUG *)
  4.   (* $StackChk- $OvflChk- $RangeChk- $CaseChk- $ReturnChk- $NilChk- $TypeChk- $OddChk- $ClearVars- *)
  5. (* $END *)
  6.  
  7. (* /// ------------------------------- "IMPORT" -------------------------------- *)
  8. IMPORT  a:=CyberAVIAudio,
  9.         asl:=ASL,
  10.         as:=ASLSupport,
  11.         cu:=CyberAVIUtils,
  12.         d:=Dos,
  13.         ds:=DosSupport,
  14.         e:=Exec,
  15.         g:=CyberAVIGlobals,
  16.         i2m:=Intel2Mot,
  17.         ic:=Icon,
  18.         io:=AsyncIOSupport,
  19.         mu:=MathUtils,
  20.         o:=CyberAVIOpts,
  21.         ol:=OberonLib,
  22.         s:=CyberAVISync,
  23.         u:=Utility,
  24. (* /// "$IF DEBUG" *)
  25.         NoGuru,
  26.         Break,
  27. (* \\\ $END *)
  28.         v:=CyberAVIVideo,
  29.         wb:=Workbench,
  30.         y:=SYSTEM;
  31. (* \\\ ------------------------------------------------------------------------- *)
  32.  
  33. (* /// -------------------------------- "TYPE" --------------------------------- *)
  34. TYPE    IndexEntryPtr=UNTRACED POINTER TO IndexEntry;
  35.         IndexEntry=STRUCT
  36.             id: LONGINT;
  37.             flags: LONGSET;
  38.             offset: LONGINT;
  39.             size: LONGINT;
  40.             isKey: BOOLEAN;
  41.             frameType: LONGINT;
  42.             streamNum: LONGINT;
  43.         END;
  44.         IndexPtr=UNTRACED POINTER TO ARRAY OF IndexEntry;
  45.  
  46.         Chunk=STRUCT
  47.             id: LONGINT;
  48.             size: LONGINT;
  49.         END;
  50. (* \\\ ------------------------------------------------------------------------- *)
  51.  
  52. (* /// -------------------------------- "CONST" -------------------------------- *)
  53. CONST
  54. (* $IF RUNDEBUG *)
  55.         template="FILES/M,"
  56.  
  57.                  "PUBSCREEN/K,"
  58.                  "SCREENMODEREQ=SMR/S,"
  59.                  "SCREENMODEID=SMID/K,"
  60.  
  61.                  "FORCE24/S,"
  62.                  "GRAY=GREY/S,"
  63.                  "AGA/S,"
  64.                  "HAM8/S,"
  65.                  "DITHER/S,"
  66.                  "CMAP/K,"
  67.  
  68.                  "BUFFERSIZE=BUF/K/N,"
  69.                  "DELAY/K/N,"
  70.  
  71.                  "LOOP/S,"
  72.                  "MAXFPS/S,"
  73.                  "NOINDEX/S,"
  74.                  "NOSOUND/S,"
  75.                  "NOVIDEO/S,"
  76.                  "SKIP/S,"
  77.                  "MAGNIFY/K/N,"
  78.  
  79.                  "STATS/S,"
  80.                  "QUIET/S"
  81.  
  82.                  ",DEBUG/S";
  83. (* $ELSE *)
  84.         template="FILES/M,"
  85.  
  86.                  "PUBSCREEN/K,"
  87.                  "SCREENMODEREQ=SMR/S,"
  88.                  "SCREENMODEID=SMID/K,"
  89.  
  90.                  "FORCE24/S,"
  91.                  "GRAY=GREY/S,"
  92.                  "AGA/S,"
  93.                  "HAM8/S,"
  94.                  "DITHER/S,"
  95.                  "CMAP/K,"
  96.  
  97.                  "BUFFERSIZE=BUF/K/N,"
  98.                  "DELAY/K/N,"
  99.  
  100.                  "LOOP/S,"
  101.                  "MAXFPS/S,"
  102.                  "NOINDEX/S,"
  103.                  "NOSOUND/S,"
  104.                  "NOVIDEO/S,"
  105.                  "SKIP/S,"
  106.                  "MAGNIFY/K/N,"
  107.  
  108.                  "STATS/S,"
  109.                  "QUIET/S"
  110.  
  111.                  "";
  112. (* $END *)
  113.  
  114. (* $IF BETA *)
  115.         version="$VER: CyberAVI 1.12 beta 1, time limit is 31-Jan-98 (27.9.97)"
  116.                 "\oCyberAVI is ©1996-1997 Thore Böckelmann";
  117.         expireDate=7336; (* = 31.1.98 *)
  118. (* $ELSE *)
  119.         version="$VER: CyberAVI 1.12 (20.1.98)"
  120.                 "\oCyberAVI is ©1996-1997 Thore Böckelmann";
  121. (* $END *)
  122.  
  123.         idRIFF=y.VAL(LONGINT,"RIFF");
  124.         idLIST=y.VAL(LONGINT,"LIST");
  125.         idavih=y.VAL(LONGINT,"avih");
  126.         idstrd=y.VAL(LONGINT,"strd");
  127.         idstrh=y.VAL(LONGINT,"strh");
  128.         idstrf=y.VAL(LONGINT,"strf");
  129.         ididx1=y.VAL(LONGINT,"idx1");
  130.  
  131.         idAVI =y.VAL(LONGINT,"AVI ");
  132.  
  133.         idhdrl=y.VAL(LONGINT,"hdrl");
  134.         idstrl=y.VAL(LONGINT,"strl");
  135.  
  136.         idvids=y.VAL(LONGINT,"vids");
  137.         idauds=y.VAL(LONGINT,"auds");
  138.         idpads=y.VAL(LONGINT,"pads");
  139.  
  140.  
  141.         idmovi=y.VAL(LONGINT,"movi");
  142.         idrec =y.VAL(LONGINT,"rec ");
  143.  
  144.  
  145.         id0021=y.VAL(LONGINT,"0021");
  146.         id0031=y.VAL(LONGINT,"0031");
  147.         id0032=y.VAL(LONGINT,"0032");
  148.         id00dx=y.VAL(LONGINT,"00dx");
  149.         id00id=y.VAL(LONGINT,"00id");
  150.         id00iv=y.VAL(LONGINT,"00iv");
  151.         id00rt=y.VAL(LONGINT,"00rt");
  152.         id00vc=y.VAL(LONGINT,"00vc");
  153.         id00xm=y.VAL(LONGINT,"00xm");
  154.         id00xx=y.VAL(LONGINT,"00xx");
  155.  
  156.         id00db=y.VAL(LONGINT,"00db");
  157.         id01db=y.VAL(LONGINT,"01db");
  158.         idxxdb=y.VAL(LONGINT,"\o\odb");
  159.         id00dc=y.VAL(LONGINT,"00dc");
  160.         id01dc=y.VAL(LONGINT,"01dc");
  161.         idxxdc=y.VAL(LONGINT,"\o\odc");
  162.  
  163.         id00pc=y.VAL(LONGINT,"00pc");
  164.         id01pc=y.VAL(LONGINT,"01pc");
  165.         idxxpc=y.VAL(LONGINT,"\o\opc");
  166.  
  167.         id00wb=y.VAL(LONGINT,"00wb");
  168.         id01wb=y.VAL(LONGINT,"01wb");
  169.         idxxwb=y.VAL(LONGINT,"\o\owb");
  170.  
  171.  
  172.         ahHasIndex=4;
  173.         ahMustUseIndex=5;
  174.         ahIsInterleaved=8;
  175.         ahWasCaptureFile=16;
  176.         ahCopyrighted=17;
  177.  
  178.  
  179.         ashDisabled=0;
  180.         ashVideoPalChanges=16;
  181.  
  182.  
  183.         aieList=0;
  184.         aieTwoCC=1;
  185.         aieKeyframe=4;
  186.         aieFirstPart=5;
  187.         aieLastPart=6;
  188.         aieMidPart=LONGSET{aieFirstPart,aieLastPart};
  189.         aieNoTime=8;
  190.         aieCompUse=y.VAL(LONGSET,0FFF0000H);
  191.  
  192.         listHeadSize=SIZE(Chunk)+SIZE(LONGINT);
  193. (* \\\ ------------------------------------------------------------------------- *)
  194.  
  195. (* /// --------------------------------- "VAR" --------------------------------- *)
  196. VAR     fileReq: asl.FileRequesterPtr;
  197.         index: IndexPtr;
  198.         indexEntries: LONGINT;
  199.         useIndex: BOOLEAN;
  200.         doVideo: BOOLEAN;
  201.         doAudio: BOOLEAN;
  202.         videoStream: LONGINT;
  203.         audioStream: LONGINT;
  204.         lastSTRH: LONGINT;
  205.         onlyKeyframes: BOOLEAN;
  206.         preLoaded: BOOLEAN;
  207.         pause: BOOLEAN;
  208. (* /// "$IF BETA" *)
  209.         now: d.Date;
  210.         expire: d.Date;
  211. (* \\\ $END *)
  212. (* \\\ ------------------------------------------------------------------------- *)
  213.  
  214. (* /// ------------------------ "PROCEDURE ReadAVIH()" ------------------------- *)
  215. PROCEDURE ReadAVIH(size: LONGINT): BOOLEAN;
  216.  
  217. VAR     head: g.AVIHeader;
  218.         forceIndex: BOOLEAN;
  219.  
  220. BEGIN
  221.   IF size#038H THEN RETURN FALSE; END;
  222.   head.microsPerFrame:=io.GetLSBLong();
  223.   head.maxBytesPerSec:=io.GetLSBLong();
  224.   head.reserved:=io.GetMSBLong();
  225.   head.flags:=io.GetLSBLSet();
  226.   head.totalFrames:=io.GetLSBLong();
  227.   head.initialFrames:=io.GetLSBLong();
  228.   head.streams:=io.GetLSBLong();
  229.   head.suggestedBufferSize:=io.GetLSBLong();
  230.   head.width:=io.GetLSBLong();
  231.   head.height:=io.GetLSBLong();
  232.   head.scale:=io.GetLSBLong();
  233.   head.rate:=io.GetLSBLong();
  234.   head.start:=io.GetLSBLong();
  235.   head.length:=io.GetLSBLong();
  236. (* /// "$IF RUNDEBUG" *)
  237.   IF o.debug THEN
  238.     d.PrintF("  µs: %ld\n"
  239.              "  bytes/sec: %ld\n"
  240.              "  flags: $%08lx =",head.microsPerFrame,head.maxBytesPerSec,head.flags);
  241.     IF ahHasIndex IN head.flags THEN d.PrintF(" hasindex"); END;
  242.     IF ahMustUseIndex IN head.flags THEN d.PrintF(" useindex"); END;
  243.     IF ahIsInterleaved IN head.flags THEN d.PrintF(" interleaved"); END;
  244.     IF ahWasCaptureFile IN head.flags THEN d.PrintF(" capture"); END;
  245.     IF ahCopyrighted IN head.flags THEN d.PrintF(" copyright"); END;
  246.     d.PrintF("\n"
  247.              "  total frames: %ld\n"
  248.              "  initial frames: %ld\n"
  249.              "  streams: %ld\n"
  250.              "  buffer size: %ld\n"
  251.              "  width: %ld\n"
  252.              "  height: %ld\n"
  253.              "  scale: %ld\n"
  254.              "  rate: %ld\n"
  255.              "  start: %ld\n"
  256.              "  length: %ld\n\n",head.totalFrames,head.initialFrames,head.streams,head.suggestedBufferSize,head.width,head.height,head.scale,head.rate,head.start,head.length);
  257.   END;
  258. (* \\\ $END *)
  259.   g.animInfo.avih:=head;
  260.  
  261.   useIndex:=(ahHasIndex IN head.flags) & ~o.noIndex;
  262.   forceIndex:=(ahMustUseIndex IN head.flags);
  263.   IF forceIndex & ~useIndex THEN d.PrintF("AVI file must use index but there is none. Playback may be corrupted!\n"); END;
  264.   IF o.doSkip & ~(ahHasIndex IN head.flags) & ~o.noIndex THEN d.PrintF("AVI file has no index, skipping of delayed frames is not possible!\n"); END;
  265.  
  266.   RETURN TRUE;
  267. END ReadAVIH;
  268. (* \\\ ------------------------------------------------------------------------- *)
  269.  
  270. (* /// ------------------------ "PROCEDURE ReadSTRH()" ------------------------- *)
  271. PROCEDURE ReadSTRH(size: LONGINT): BOOLEAN;
  272.  
  273. VAR     head: g.AVIStreamHeader;
  274.  
  275. BEGIN
  276.   IF size<024H THEN RETURN FALSE; END;
  277.   head.fccType:=io.GetMSBLong();
  278.   head.fccHandler:=io.GetMSBLong();
  279.   head.flags:=io.GetLSBLSet();
  280.   head.priority:=io.GetLSBLong();
  281.   head.initialFrames:=io.GetLSBLong();
  282.   head.scale:=io.GetLSBLong();
  283.   head.rate:=io.GetLSBLong();
  284.   head.start:=io.GetLSBLong();
  285.   head.length:=io.GetLSBLong();
  286.   head.suggestedBufferSize:=io.GetLSBLong();
  287.   head.quality:=io.GetLSBLong();
  288.   head.sampleSize:=io.GetLSBLong();
  289.   DEC(size,48);
  290. (* /// "$IF RUNDEBUG" *)
  291.   IF o.debug THEN
  292.     d.PrintF("  type: "); cu.PrintFCC(head.fccType); d.PrintF("\n");
  293.     d.PrintF("  handler: "); cu.PrintFCC(head.fccHandler); d.PrintF("\n");
  294.     d.PrintF("  flags: $%08lx =",head.flags);
  295.     IF ashDisabled IN head.flags THEN d.PrintF(" disabled"); END;
  296.     IF ashVideoPalChanges IN head.flags THEN d.PrintF(" palette-change"); END;
  297.     d.PrintF("\n"
  298.              "  priority: %ld\n"
  299.              "  initial frames: %ld\n"
  300.              "  scale: %ld\n"
  301.              "  rate: %ld\n"
  302.              "  start: %ld\n"
  303.              "  length: %ld\n"
  304.              "  buffer size: %ld\n"
  305.              "  quality: %ld\n"
  306.              "  sample size: %ld\n\n",head.priority,head.initialFrames,head.scale,head.rate,head.start,head.length,head.suggestedBufferSize,head.quality,head.sampleSize);
  307.   END;
  308. (* \\\ $END *)
  309.   IF size>0 THEN io.Skip(size); END;
  310.   IF size<0 THEN RETURN FALSE; END; (* irgendwas ist faul *)
  311.  
  312.   lastSTRH:=head.fccType;
  313.   CASE head.fccType OF
  314.   | idvids: g.animInfo.vids.strh:=head;
  315.   | idauds: g.animInfo.auds.strh:=head;
  316.   ELSE
  317.   END;
  318.   RETURN TRUE;
  319. END ReadSTRH;
  320. (* \\\ ------------------------------------------------------------------------- *)
  321.  
  322. (* /// ------------------------ "PROCEDURE ReadVIDS()" ------------------------- *)
  323. PROCEDURE ReadVIDS(size: LONGINT): BOOLEAN;
  324.  
  325. VAR     head: g.VIDS;
  326.         colorCnt: LONGINT;
  327.  
  328. BEGIN
  329.   head.size:=io.GetLSBLong();
  330.   head.width:=io.GetLSBLong();
  331.   head.height:=io.GetLSBLong();
  332.   head.planes:=io.GetLSBShort();
  333.   head.bitCnt:=io.GetLSBShort();
  334.   head.compression:=io.GetMSBLong();
  335.   head.imageSize:=io.GetLSBLong();
  336.   head.xPelsPerMeter:=io.GetLSBLong();
  337.   head.yPelsPerMeter:=io.GetLSBLong();
  338.   head.clrUsed:=io.GetLSBLong();
  339.   head.clrImportant:=io.GetLSBLong();
  340.   DEC(size,SIZE(head));
  341. (* /// "$IF RUNDEBUG" *)
  342.   IF o.debug THEN
  343.     d.PrintF("  size: %ld\n"
  344.              "  width: %ld\n"
  345.              "  height: %ld\n"
  346.              "  planes: %ld\n"
  347.              "  bit count: %ld\n  compression: ",head.size,head.width,head.height,head.planes,head.bitCnt);
  348.     cu.PrintFCC(head.compression); d.PrintF("\n");
  349.     d.PrintF("  image size: %ld\n"
  350.              "  xpels: %ld\n"
  351.              "  ypels: %ld\n"
  352.              "  color used: %ld\n"
  353.              "  color important: %ld\n",head.imageSize,head.xPelsPerMeter,head.yPelsPerMeter,head.clrUsed,head.clrImportant);
  354.   END;
  355. (* \\\ $END *)
  356.   IF (head.clrUsed=0) & (head.bitCnt<16) THEN head.clrUsed:=y.VAL(LONGINT,LONGSET{head.bitCnt}); END;
  357.   g.animInfo.vids.strf:=head;
  358.  
  359.   colorCnt:=head.clrUsed;
  360.  
  361.   IF head.bitCnt>8 THEN
  362.     v.ReadColorMap(0,FALSE); (* bei TrueColor nur gray-Flag setzen *)
  363.   ELSE
  364. (* /// "$IF RUNDEBUG" *)
  365.     IF o.debug THEN d.PrintF("  reading color table, size: %ld = %ld entries\n",size,size DIV 4); END;
  366. (* \\\ $END *)
  367.     v.ReadColorMap(colorCnt,ashVideoPalChanges IN g.animInfo.vids.strh.flags);
  368.     DEC(size,colorCnt*4); (* 4 Byte pro Farbe *)
  369.   END;
  370.   IF size>0 THEN io.Skip(size); END;
  371.   IF size<0 THEN RETURN FALSE; END; (* irgendwas ist faul *)
  372. (* /// "$IF RUNDEBUG" *)
  373.   IF o.debug THEN d.PrintF("\n"); END;
  374. (* \\\ $END *)
  375.  
  376.   IF v.AllocBuffers() THEN
  377.     doVideo:=~o.noVideo;
  378.   ELSE
  379.     doVideo:=FALSE;
  380.   END;
  381.  
  382.   RETURN TRUE;
  383. END ReadVIDS;
  384. (* \\\ ------------------------------------------------------------------------- *)
  385.  
  386. (* /// ------------------------ "PROCEDURE ReadAUDS()" ------------------------- *)
  387. PROCEDURE ReadAUDS(size: LONGINT): BOOLEAN;
  388.  
  389. VAR     head: g.AUDS;
  390.  
  391. BEGIN
  392.   head.format:=io.GetLSBShort();
  393.   head.channels:=io.GetLSBShort();
  394.   head.samplesPerSec:=io.GetLSBLong();
  395.   head.avgBytesPerSec:=io.GetLSBLong();
  396.   head.blockAlign:=io.GetLSBShort();
  397.   head.bitsPerSample:=io.GetLSBShort();
  398.   head.extSize:=0;
  399.   IF size<16 THEN
  400.     head.bitsPerSample:=8;
  401.     DEC(size,14);
  402.   ELSE
  403.     IF size>16 THEN
  404.       head.extSize:=io.GetLSBShort();
  405.       DEC(size,18);
  406.       IF size=0 THEN head.extSize:=0; END; (* Workaround für AVIs mit falschen ExtSize-Werten, 18 statt 0 *)
  407.     ELSE
  408.       DEC(size,16);
  409.     END;
  410.   END;
  411. (* /// "$IF RUNDEBUG" *)
  412.   IF o.debug THEN
  413.     d.PrintF("  codec: %ld\n"
  414.              "  channels: %ld\n"
  415.              "  samples/sec: %ld\n"
  416.              "  average bytes/sec: %ld\n"
  417.              "  align: %ld\n"
  418.              "  bits per sample: %ld\n"
  419.              "  extended size: %ld\n\n",head.format,head.channels,head.samplesPerSec,head.avgBytesPerSec,head.blockAlign,head.bitsPerSample,head.extSize);
  420.   END;
  421. (* \\\ $END *)
  422.   g.animInfo.auds.strf:=head;
  423.  
  424.   a.ReadExtension(head.extSize);
  425.   DEC(size,head.extSize);
  426.   IF size>0 THEN io.Skip(size); END;
  427.   IF size<0 THEN RETURN FALSE; END; (* irgendwas ist faul *)
  428.  
  429.   IF a.AllocBuffers() THEN
  430.     doAudio:=~o.noSound & a.audioOpen;
  431.   ELSE
  432.     doAudio:=FALSE;
  433.   END;
  434.  
  435.   RETURN TRUE;
  436. END ReadAUDS;
  437. (* \\\ ------------------------------------------------------------------------- *)
  438.  
  439. (* /// ------------------------ "PROCEDURE ReadHDRL()" ------------------------- *)
  440. PROCEDURE ReadHDRL(size: LONGINT): LONGINT;
  441.  
  442. VAR     ckID: LONGINT;
  443.         ckSize: LONGINT;
  444.         listID: LONGINT;
  445.         errVal: LONGINT;
  446.         streamCnt: INTEGER;
  447.  
  448. BEGIN
  449.   IF ODD(size) THEN INC(size); END;
  450.   streamCnt:=0;
  451.   videoStream:=-1;
  452.   audioStream:=-1;
  453.   errVal:=g.noError;
  454.   LOOP
  455.     ckID:=io.GetMSBLong();
  456.     ckSize:=io.GetLSBLong();
  457. (* /// "$IF RUNDEBUG" *)
  458.     IF o.debug THEN
  459.       cu.PrintChunkHead(ckID,ckSize);
  460.       IF ckID=idLIST THEN
  461.         d.PrintF(" subID: ");
  462.       ELSE
  463.         d.PrintF("\n");
  464.       END;
  465.     END;
  466. (* \\\ $END *)
  467.     CASE ckID OF
  468.     | idLIST:
  469.         listID:=io.GetMSBLong();
  470. (* /// "$IF RUNDEBUG" *)
  471.         IF o.debug THEN cu.PrintFCC(listID); d.PrintF("\n"); END;
  472. (* \\\ $END *)
  473.         INC(size,ckSize-4);
  474.     | idavih: IF ~ReadAVIH(ckSize) THEN errVal:=g.unknownError; END;
  475.     | idstrh: IF ~ReadSTRH(ckSize) THEN errVal:=g.unknownError; END;
  476.     | idstrf:
  477.         IF streamCnt>=g.animInfo.avih.streams THEN
  478.           d.PrintF("Too many streams!\n");
  479.           errVal:=g.unknownError;
  480.         ELSE
  481.           CASE lastSTRH OF
  482.           | idvids:
  483.             IF videoStream=-1 THEN
  484.               IF ~ReadVIDS(ckSize) THEN errVal:=g.unknownError; END;
  485.               videoStream:=streamCnt;
  486.             ELSE
  487.               d.PrintF("Too many video streams!\n");
  488.               errVal:=g.unknownError;
  489.             END;
  490.           | idauds:
  491.             IF audioStream=-1 THEN
  492.               IF ~ReadAUDS(ckSize) THEN errVal:=g.unknownError; END;
  493.               audioStream:=streamCnt;
  494.             ELSE
  495.               d.PrintF("Too many audio streams!\n");
  496.               errVal:=g.unknownError;
  497.             END;
  498.           ELSE
  499.             io.Skip(ckSize);
  500.           END;
  501.           INC(streamCnt);
  502.         END;
  503.     ELSE
  504.       io.Skip(ckSize);
  505.     END;
  506.  
  507.     DEC(size,ckSize+8);
  508.     IF size<=0 THEN EXIT; END;
  509.  
  510.     IF ~io.readOk THEN errVal:=g.readError; END;
  511.  
  512.     IF errVal#g.noError THEN EXIT; END;
  513.   END;
  514.  
  515.   RETURN errVal;
  516. END ReadHDRL;
  517. (* \\\ ------------------------------------------------------------------------- *)
  518.  
  519. (* /// ---------------------- "PROCEDURE HandleEvents()" ----------------------- *)
  520. PROCEDURE HandleEvents(): LONGINT;
  521.  
  522. VAR     sigs: LONGSET;
  523.         received: LONGSET;
  524.         ret: LONGINT;
  525.  
  526. BEGIN
  527.   ret:=g.noError;
  528.   sigs:=LONGSET{s.timerSig,v.idcmpSig,d.ctrlC,d.ctrlD};
  529.   LOOP
  530.     received:=e.Wait(sigs+a.audioSigs);
  531.     IF doAudio THEN a.PlaySample(FALSE); END;
  532.     IF v.idcmpSig IN received THEN ret:=v.HandleIDCMP(); END;
  533.     IF s.timerSig IN received THEN EXIT END;
  534.     IF d.ctrlC IN received THEN ret:=d.break; END;
  535.     IF d.ctrlD IN received THEN ret:=g.skipAnim; END;
  536.     IF ret=g.pauseAnim THEN
  537.       ret:=g.noError;
  538.       pause:=~pause;
  539.       a.PauseSound(pause);
  540.       s.PauseTimer(pause);
  541.       IF pause THEN
  542.         EXCL(sigs,s.timerSig);
  543.       ELSE
  544.         INCL(sigs,s.timerSig);
  545.       END;
  546.     END;
  547.     IF ret#g.noError THEN EXIT; END;
  548.   END;
  549.   RETURN ret;
  550. END HandleEvents;
  551. (* \\\ ------------------------------------------------------------------------- *)
  552.  
  553. (* /// ---------------------- "PROCEDURE ParseMOVIFile()" ---------------------- *)
  554. PROCEDURE ParseMOVIFile(size: LONGINT;
  555.                         fileName: e.STRPTR): LONGINT;
  556.  
  557. VAR     ckID: LONGINT;
  558.         ckSize: LONGINT;
  559.         errVal: LONGINT;
  560.         stream: LONGINT;
  561.         type: LONGINT;
  562.         framesDone: LONGINT;
  563.         firstVFrame: BOOLEAN;
  564.         sigs: LONGSET;
  565.  
  566.         loopBegin: LONGINT;
  567.         loopSize: LONGINT;
  568.         listID: LONGINT;
  569.  
  570. BEGIN
  571.   IF a.mustPreload THEN
  572.     d.PrintF("This animation seems to have only one audio chunk.\n"
  573.              "CyberAVI is unable to play this audio stream without index.\n");
  574.     doAudio:=FALSE;
  575.   END;
  576.   IF o.doLoop THEN
  577.     loopBegin:=io.FilePos();
  578.     IF loopBegin=-1 THEN RETURN 1; END;
  579.     loopSize:=size;
  580.   END;
  581.   errVal:=v.OpenDisplay(~doVideo,fileName);
  582.   IF errVal#g.noError THEN
  583.     v.CloseDisplay();
  584.     RETURN errVal;
  585.   END;
  586.   firstVFrame:=~doVideo;
  587.   framesDone:=0;
  588.   IF o.maxFPS THEN
  589.     s.SetFrameDelay(0);
  590.   ELSE
  591.     s.SetFrameDelay(-1);
  592.   END;
  593.   IF doVideo THEN s.Wait(o.startDelay); END;
  594.   LOOP
  595.     ckID:=io.GetMSBLong();
  596.     ckSize:=io.GetLSBLong();
  597. (* /// "$IF RUNDEBUG" *)
  598.     IF o.debug THEN d.PrintF("movi id: "); cu.PrintFCC(ckID); d.PrintF(", size: %ld\n",ckSize); END;
  599. (* \\\ $END *)
  600.     IF ckID=idLIST THEN
  601.       listID:=io.GetMSBLong();
  602. (* /// "$IF RUNDEBUG" *)
  603.       IF o.debug THEN d.PrintF("movi list sub id: "); cu.PrintFCC(listID); d.PrintF("\n"); END;
  604. (* \\\ $END *)
  605.       INC(size,ckSize-4);
  606.     ELSE
  607. (* $RangeChk- *)
  608.       stream:=y.LSH(ckID,-16)-03030H; (* nur die beiden vorderen Zeichen in Zahl umwandeln *)
  609.       type:=y.VAL(LONGINT,y.VAL(LONGSET,ckID)*LONGSET{0..15});
  610. (* $RangeChk= *)
  611.       IF (stream=videoStream) & doVideo THEN
  612.         IF type=idxxpc THEN
  613.           v.ChangeColorMap(ckSize);
  614.         ELSE (* Video, aber keine Palette => Bild *)
  615.           firstVFrame:=(framesDone=1) OR (g.animInfo.vids.strh.length=1); (* entweder wird 2. Bild bearbeitet, oder es gibt nur ein einziges *)
  616.           IF framesDone=0 THEN s.StartTimer(); END;
  617.           errVal:=HandleEvents();
  618.           v.DecodeFrame(ckSize,(type=idxxdb));
  619.           INC(framesDone);
  620.           s.DoFrameDelay(FALSE);
  621.         END;
  622.       ELSIF (stream=audioStream) & doAudio THEN
  623.         a.DecodeFrame(ckSize);
  624.       ELSE
  625.         io.Skip(ckSize);
  626.       END;
  627.     END;
  628.  
  629.     IF firstVFrame & doAudio THEN a.StartSound(); END;
  630.  
  631.     IF ODD(ckSize) THEN INC(ckSize); END;
  632.     DEC(size,ckSize+SIZE(Chunk));
  633.  
  634.     IF (size<=0) OR ((framesDone>0) & (framesDone MOD g.animInfo.avih.totalFrames=0)) THEN (* für AVIs mit falschen movi-Größen *)
  635.       a.Wait4LastSample(errVal#g.noError);
  636.       IF o.doLoop THEN
  637. (* /// "$IF RUNDEBUG" *)
  638.         IF o.debug THEN d.PrintF("looping...\n"); END;
  639. (* \\\ $END *)
  640.         io.SeekTo(loopBegin);
  641.         size:=loopSize;
  642.         v.Restore1stColorMap();
  643.       ELSE
  644.         EXIT; (* Animation am Ende *)
  645.       END;
  646.     END;
  647.  
  648.     sigs:=e.SetSignal(LONGSET{},LONGSET{d.ctrlC,d.ctrlD});
  649.     IF d.ctrlC IN sigs THEN errVal:=d.break; END;
  650.     IF d.ctrlD IN sigs THEN errVal:=g.skipAnim; END;
  651.     IF ~io.readOk THEN errVal:=g.readError; END;
  652.     IF errVal#g.noError THEN EXIT; END;
  653.   END;
  654.   s.Wait4LastFrame();
  655.   IF doVideo & o.doStats THEN s.DoStats(framesDone,0); END;
  656.   a.StopSound(errVal#g.noError);
  657.   v.CloseDisplay();
  658.   RETURN errVal;
  659. END ParseMOVIFile;
  660. (* \\\ ------------------------------------------------------------------------- *)
  661.  
  662. (* /// --------------------- "PROCEDURE ParseMOVIIndex()" ---------------------- *)
  663. PROCEDURE ParseMOVIIndex(fileName: e.STRPTR): LONGINT;
  664.  
  665. VAR     errVal: LONGINT;
  666.         framesDone: LONGINT;
  667.         firstVFrame: BOOLEAN;
  668.         sigs: LONGSET;
  669.  
  670.         idxCnt: LONGINT;
  671.         entry: IndexEntry;
  672.         skipped: LONGINT;
  673.         skipping: BOOLEAN;
  674.         vFrame: LONGINT;
  675.  
  676. BEGIN
  677.   IF a.mustPreload THEN (* nur Preload, wenn der letzte Frame ein Audioframe ist *)
  678.     IF index[indexEntries-1].frameType=idxxwb THEN
  679.       a.Preload(index[indexEntries-1].offset,index[indexEntries-1].size);
  680.     ELSE
  681.       a.mustPreload:=FALSE;
  682.     END;
  683.   END;
  684.   errVal:=v.OpenDisplay(~doVideo,fileName);
  685.   IF errVal#g.noError THEN
  686.     v.CloseDisplay();
  687.     RETURN errVal;
  688.   END;
  689.   firstVFrame:=~doVideo;
  690.   framesDone:=0;
  691.   vFrame:=0;
  692.   idxCnt:=0;
  693.   skipped:=0;
  694.   skipping:=FALSE;
  695.   IF o.maxFPS THEN
  696.     s.SetFrameDelay(0);
  697.   ELSE
  698.     s.SetFrameDelay(-1);
  699.   END;
  700.   IF doVideo THEN s.Wait(o.startDelay); END;
  701.   LOOP
  702.     entry:=index[idxCnt];
  703. (* /// "$IF RUNDEBUG" *)
  704.     IF o.debug THEN
  705.       d.PrintF("\nindex entry %4ld: id: ",idxCnt); cu.PrintFCC(entry.id); d.PrintF("\n");
  706.       d.PrintF("                  size: %ld\n",entry.size);
  707.       d.PrintF("                  flags: $%08lx = ",entry.flags);
  708.       IF aieList IN entry.flags THEN d.PrintF("list "); END;
  709.       IF aieTwoCC IN entry.flags THEN d.PrintF("twocc "); END;
  710.       IF aieKeyframe IN entry.flags THEN d.PrintF("keyframe "); END;
  711.       IF aieFirstPart IN entry.flags THEN d.PrintF("firstpart "); END;
  712.       IF aieLastPart IN entry.flags THEN d.PrintF("lastpart "); END;
  713.       IF aieNoTime IN entry.flags THEN d.PrintF("notime "); END;
  714.       d.PrintF("\n");
  715.     END;
  716. (* \\\ $END *)
  717.     IF entry.id#idrec THEN
  718.       IF (entry.streamNum=videoStream) & doVideo THEN
  719.         io.SeekTo(entry.offset);
  720.         IF entry.frameType=idxxpc THEN
  721.           v.ChangeColorMap(entry.size);
  722.         ELSE (* Video, aber keine Palette => Bild *)
  723.           firstVFrame:=(framesDone=1) OR (g.animInfo.vids.strh.length=1); (* entweder wird 2. Bild bearbeitet, oder es gibt nur ein einziges *)
  724.           IF framesDone=0 THEN s.StartTimer(); END;
  725.           errVal:=HandleEvents();
  726.           IF skipping & entry.isKey & ~onlyKeyframes THEN skipping:=FALSE; END;
  727.           IF skipping THEN
  728.             INC(skipped);
  729.           ELSE
  730.             v.DecodeFrame(entry.size,(entry.frameType=idxxdb));
  731.           END;
  732.           s.DoFrameDelay(skipping);
  733.           skipping:=o.doSkip &
  734.                     ~s.IsSync() &
  735.                     (~entry.isKey OR onlyKeyframes) OR
  736.                     (skipping & ~onlyKeyframes);
  737.           INC(framesDone);
  738.           INC(vFrame);
  739.         END;
  740.       ELSIF (entry.streamNum=audioStream) & doAudio & ~a.mustPreload THEN
  741.         io.SeekTo(entry.offset);
  742.         a.DecodeFrame(entry.size);
  743.       ELSE
  744.         (* irgendwas anderes als Audio oder Video *)
  745.       END;
  746.     END;
  747.  
  748.     IF doAudio THEN
  749.       a.PlaySample(~doVideo);
  750.       IF firstVFrame THEN a.StartSound(); END;
  751.     END;
  752.  
  753.     INC(idxCnt);
  754.     IF idxCnt=indexEntries THEN
  755.       a.Wait4LastSample(errVal#g.noError);
  756.       IF o.doLoop THEN
  757. (* /// "$IF RUNDEBUG" *)
  758.         IF o.debug THEN d.PrintF("looping...\n"); END;
  759. (* \\\ $END *)
  760.         idxCnt:=0;
  761.         vFrame:=0;
  762.         v.Restore1stColorMap();
  763.       ELSE
  764.         EXIT;
  765.       END;
  766.     END;
  767.  
  768.     sigs:=e.SetSignal(LONGSET{},LONGSET{d.ctrlC,d.ctrlD});
  769.     IF d.ctrlC IN sigs THEN errVal:=d.break; END;
  770.     IF d.ctrlD IN sigs THEN errVal:=g.skipAnim; END;
  771.     IF ~io.readOk THEN errVal:=g.readError; END;
  772.     IF errVal#g.noError THEN EXIT; END;
  773.   END;
  774.   s.Wait4LastFrame();
  775.   IF doVideo & o.doStats THEN s.DoStats(framesDone,skipped); END;
  776.   a.StopSound(errVal#g.noError);
  777.   v.CloseDisplay();
  778.   RETURN errVal;
  779. END ParseMOVIIndex;
  780. (* \\\ ------------------------------------------------------------------------- *)
  781.  
  782. (* /// ------------------------ "PROCEDURE ReadIDX1()" ------------------------- *)
  783. PROCEDURE ReadIDX1(size: LONGINT;
  784.                    relStart: LONGINT): BOOLEAN;
  785.  
  786. TYPE    AVIIndexEntry=STRUCT
  787.             id: LONGINT;
  788.             flags: LONGSET;
  789.             offset: LONGINT;
  790.             size: LONGINT;
  791.         END;
  792.  
  793. VAR     cnt: LONGINT;
  794.         audioFrames: LONGINT;
  795.         minOffset: LONGINT;
  796.         keyCount: LONGINT;
  797.         entry: AVIIndexEntry;
  798.         flags: LONGSET;
  799.  
  800. BEGIN
  801.   DISPOSE(index);
  802.   indexEntries:=(size+15) DIV 16;
  803. (* /// "$IF RUNDEBUG" *)
  804.   IF o.debug THEN d.PrintF("\nreading index, %ld entries\n",indexEntries); END;
  805. (* \\\ $END *)
  806.   NEW(index,indexEntries*SIZE(IndexEntry));
  807.   minOffset:=MAX(LONGINT);
  808.   keyCount:=0;
  809.   FOR cnt:=0 TO indexEntries-1 DO
  810.     io.Read(y.ADR(entry),SIZE(AVIIndexEntry));
  811.     index[cnt].id:=entry.id;
  812.     flags:=i2m.LSB2MSBLSet(entry.flags);
  813.     index[cnt].flags:=flags;
  814.     index[cnt].offset:=i2m.LSB2MSBLong(entry.offset);
  815.     index[cnt].size:=i2m.LSB2MSBLong(entry.size);
  816.     index[cnt].isKey:=(aieKeyframe IN flags);
  817.     IF aieKeyframe IN flags THEN INC(keyCount); END;
  818.     index[cnt].frameType:=y.VAL(LONGINT,y.VAL(LONGSET,entry.id)*LONGSET{0..15});
  819.     index[cnt].streamNum:=y.LSH(entry.id,-16)-03030H;
  820.     minOffset:=mu.min(index[cnt].offset,minOffset);
  821.     IF ~io.readOk THEN RETURN FALSE; END;
  822.   END;
  823.   IF minOffset=relStart THEN (* relativ zum Dateianfang? *)
  824. (* /// "$IF RUNDEBUG" *)
  825.     IF o.debug THEN d.PrintF("index seems to be corrupted, setting new relative start from %ld to %ld\n",relStart,SIZE(Chunk)); END;
  826. (* \\\ $END *)
  827.     relStart:=SIZE(Chunk); (* RIFFxxxx wird beim Offset zum Dateianfang nicht mitgezählt *)
  828.   ELSE
  829.     INC(relStart,SIZE(LONGINT));
  830.   END;
  831.   FOR cnt:=0 TO indexEntries-1 DO INC(index[cnt].offset,relStart); END;
  832.   keyCount:=mu.max(1,keyCount);
  833.   onlyKeyframes:=(keyCount>=g.animInfo.avih.totalFrames);
  834.   IF (g.animInfo.avih.totalFrames DIV keyCount>s.GetFPS()) & o.doSkip THEN
  835.     d.PrintF("Not enough key frames, possible skips may produce wrong frames.\n");
  836.   END;
  837.   RETURN TRUE;
  838. END ReadIDX1;
  839. (* \\\ ------------------------------------------------------------------------- *)
  840.  
  841. (* /// ------------------------ "PROCEDURE ParseRIFF()" ------------------------ *)
  842. PROCEDURE ParseRIFF(ap: d.AnchorPathPtr;
  843.                     multi: BOOLEAN): LONGINT;
  844.  
  845. VAR     errVal: LONGINT;
  846.         ckID: LONGINT;
  847.         subID: LONGINT;
  848.         ckSize: LONGINT;
  849.         moviStart: LONGINT;
  850.         moviSize: LONGINT;
  851.         riffSize: LONGINT;
  852.         riffSizeAtMOVI: LONGINT;
  853.         indexRead: BOOLEAN;
  854.         fileNamePtr: e.STRPTR;
  855.  
  856. BEGIN
  857.   NEW(fileNamePtr);
  858.   COPY(ap.info.fileName,fileNamePtr^);
  859.   IF multi & ~o.quiet THEN
  860.     d.PrintF("%s: ",y.ADR(ap.info.fileName));
  861.     y.SETREG(0,d.Flush(d.Output()));
  862.   END;
  863.  
  864.   IF ~io.Open(ap.info.fileName,o.bufferSize) THEN RETURN d.IoErr(); END;
  865.   ckID:=io.GetMSBLong(); (* sollte "RIFF" sein *)
  866.   riffSize:=io.GetLSBLong();
  867.   subID:=io.GetMSBLong(); (* sollte "AVI " sein *)
  868.   IF (ckID#idRIFF) OR (subID#idAVI) THEN RETURN d.objectWrongType; END;
  869.   IF riffSize+8>ap.info.size THEN d.PrintF("Filesize is %lD, but should be %lD. Playback may be corrupted or even impossible!\n",ap.info.size,riffSize+8); END;
  870.   DEC(riffSize,4);
  871.  
  872.   errVal:=g.noError;
  873.   useIndex:=FALSE;
  874.   indexRead:=FALSE;
  875.   doVideo:=FALSE;
  876.   doAudio:=FALSE;
  877.   onlyKeyframes:=FALSE;
  878.   preLoaded:=FALSE;
  879.   IF ~o.quiet & multi THEN d.PrintF("\n"); END;
  880.  
  881.   REPEAT
  882.     ckID:=io.GetMSBLong();
  883.     ckSize:=io.GetLSBLong();
  884. (* /// "$IF RUNDEBUG" *)
  885.     IF o.debug THEN
  886.       d.PrintF("riff id: "); cu.PrintFCC(ckID); d.PrintF(", size: %ld",ckSize);
  887.       IF ckID#idLIST THEN d.PrintF("\n"); END;
  888.     END;
  889. (* \\\ $END *)
  890.     CASE ckID OF
  891.     | idLIST:
  892.         subID:=io.GetMSBLong();
  893.         DEC(ckSize,4);
  894.         DEC(riffSize,4);
  895. (* /// "$IF RUNDEBUG" *)
  896.         IF o.debug THEN d.PrintF(" subid: "); cu.PrintFCC(subID); d.PrintF("\n"); END;
  897. (* \\\ $END *)
  898.         CASE subID OF
  899.         | idhdrl: errVal:=ReadHDRL(ckSize);
  900.         | idmovi:
  901.             IF useIndex & ~indexRead THEN (* Index benutzten, ist aber noch nicht gelesen *)
  902. (* /// "$IF RUNDEBUG" *)
  903.               IF o.debug THEN d.PrintF("skipping MOVI to index\n"); END;
  904. (* \\\ $END *)
  905.               moviStart:=io.FilePos()-listHeadSize; (* LISTxxxmovi nochmal lesen *)
  906.               moviSize:=ckSize;
  907.               io.Skip(ckSize);
  908.               IF ~io.readOk THEN
  909.                 d.PrintF("Index seems to be lost, continuing without index. If the file was truncated playback may cause crashes!\n");
  910.                 useIndex:=FALSE;
  911.                 indexRead:=TRUE;
  912.                 io.UndoError();
  913.                 io.SeekTo(moviStart);
  914.               END;
  915.               riffSizeAtMOVI:=riffSize+4; (* LISTxxxmovi nochmal lesen *)
  916.             ELSE
  917.               IF doVideo OR doAudio THEN (* gibts überhaupt was zum Spielen? *)
  918.                 IF useIndex THEN (* Index gelesen und benutzen *)
  919. (* /// "$IF RUNDEBUG" *)
  920.                   IF o.debug THEN d.PrintF("using index\n"); END;
  921. (* \\\ $END *)
  922.                   errVal:=ParseMOVIIndex(fileNamePtr);
  923.                   io.SeekTo(moviStart+moviSize+listHeadSize); (* hinter MOVI Chunk gehen *)
  924.                 ELSE (* kein Index gefunden oder nicht benutzen *)
  925. (* /// "$IF RUNDEBUG" *)
  926.                   IF o.debug THEN d.PrintF("reading file\n"); END;
  927. (* \\\ $END *)
  928.                   errVal:=ParseMOVIFile(ckSize,fileNamePtr);
  929.                 END;
  930.               ELSE
  931.                 d.PrintF("Neither Video nor Audio to play!\n");
  932.                 riffSize:=0;
  933.               END;
  934.             END;
  935.         ELSE (* CASE subID *)
  936. (* /// "$IF RUNDEBUG" *)
  937.           IF o.debug THEN d.PrintF("unknown LIST chunk\n"); END;
  938. (* \\\ $END *)
  939.           io.Skip(ckSize);
  940.         END;
  941.     | ididx1:
  942.         IF ~indexRead & useIndex THEN
  943.           IF ~ReadIDX1(ckSize,moviStart+listHeadSize) THEN
  944.             d.PrintF("Can't read index, continuing without index\n");
  945.             useIndex:=FALSE;
  946.           ELSE
  947.             indexRead:=TRUE;
  948.           END;
  949.           io.SeekTo(moviStart);
  950.           riffSize:=riffSizeAtMOVI+ckSize+SIZE(Chunk); (* Indexlänge aufaddieren, damit Index beim 2. Mal nicht unterschlagen wird *)
  951.         ELSE
  952. (* /// "$IF RUNDEBUG" *)
  953.           IF o.debug THEN d.PrintF("skipping index\n"); END;
  954. (* \\\ $END *)
  955.           io.Skip(ckSize);
  956.         END;
  957.     ELSE
  958.       io.Skip(ckSize);
  959.     END;
  960.  
  961.     IF ODD(ckSize) THEN INC(ckSize); END;
  962.     DEC(riffSize,ckSize+SIZE(Chunk));
  963.  
  964.     IF d.ctrlC IN e.SetSignal(LONGSET{},LONGSET{d.ctrlC}) THEN errVal:=d.break; END;
  965.     IF ~io.readOk THEN errVal:=g.readError; END;
  966.   UNTIL (riffSize<=0) OR (errVal#g.noError);
  967.   IF errVal#g.noError THEN
  968.     IF errVal=g.skipAnim THEN
  969.       errVal:=g.noError;
  970.     ELSE
  971.       CASE errVal OF
  972.       | g.unknownError,
  973.         g.readError: errVal:=d.seekError;
  974.       | d.break:
  975.       ELSE
  976.         errVal:=d.IoErr();
  977.       END;
  978.     END;
  979. (* /// "$IF RUNDEBUG" *)
  980.     IF o.debug THEN d.PrintF("errVal=%ld\n",errVal); END;
  981. (* \\\ $END *)
  982.   END;
  983.   DISPOSE(fileNamePtr);
  984.   RETURN errVal;
  985. END ParseRIFF;
  986. (* \\\ ------------------------------------------------------------------------- *)
  987.  
  988. (* /// ---------------------- "PROCEDURE HandleFileReq()" ---------------------- *)
  989. PROCEDURE HandleFileReq();
  990. BEGIN
  991.   IF asl.base=NIL THEN
  992.     d.PrintF("CyberAVI needs asl.library V37+\n");
  993.   ELSE
  994.     fileReq:=asl.AllocAslRequestTags(asl.fileRequest,asl.initialPattern,y.ADR("#?.avi"),
  995.                                                      asl.doPatterns,e.true,
  996.                                                      asl.doMultiSelect,e.true,
  997.                                                      asl.titleText,y.ADR("Please select animation"),
  998.                                                      u.done);
  999.     IF fileReq#NIL THEN
  1000.       WHILE asl.AslRequestTags(fileReq,u.done) DO
  1001.         IF as.DoAllFiles(fileReq,ParseRIFF) THEN END;
  1002.       END;
  1003.       asl.FreeAslRequest(fileReq);
  1004.       fileReq:=NIL;
  1005.     END;
  1006.   END;
  1007. END HandleFileReq;
  1008. (* \\\ ------------------------------------------------------------------------- *)
  1009.  
  1010. (* /// ---------------------- "PROCEDURE HandleWBStart()" ---------------------- *)
  1011. PROCEDURE HandleWBStart();
  1012.  
  1013. VAR     icon: wb.DiskObjectPtr;
  1014.         wbs: wb.WBStartupPtr;
  1015.         name: e.STRING;
  1016.         cnt: LONGINT;
  1017.         anchor: d.AnchorPathPtr;
  1018.         oldCD: d.FileLockPtr;
  1019.         err: LONGINT;
  1020.         multi: BOOLEAN;
  1021.  
  1022. BEGIN
  1023.   wbs:=ol.wbenchMsg;
  1024.   IF wbs.numArgs=1 THEN (* ja, dann Optionen vom CyberAVI-Icon *)
  1025.     y.SETREG(0,d.NameFromLock(wbs.argList[0].lock,name,SIZE(name)));
  1026.     y.SETREG(0,d.AddPart(name,wbs.argList[0].name^,SIZE(name)));
  1027.     icon:=ic.GetDiskObject(name);
  1028.     IF icon#NIL THEN
  1029.       o.GetIconOpts(icon);
  1030.       ic.FreeDiskObject(icon);
  1031.     ELSE
  1032.       o.GetStdOpts();
  1033.     END;
  1034.     HandleFileReq();
  1035.   ELSE
  1036.     anchor:=e.AllocVec(SIZE(anchor^)+SIZE(e.STRING),e.any+LONGSET{e.memClear});
  1037.     IF anchor#NIL THEN
  1038.       anchor.strLen:=SIZE(e.STRING);
  1039.       cnt:=1;
  1040.       err:=0;
  1041.       multi:=(wbs.numArgs>2);
  1042.       REPEAT
  1043.         oldCD:=d.CurrentDir(wbs.argList[cnt].lock);
  1044.         IF wbs.argList[cnt].name^#"" THEN (* keine Verzeichnisse *)
  1045.           IF d.MatchFirst(wbs.argList[cnt].name^,anchor^)=0 THEN
  1046.             icon:=ic.GetDiskObject(anchor.info.fileName);
  1047.             IF icon#NIL THEN
  1048.               o.GetIconOpts(icon);
  1049.               ic.FreeDiskObject(icon);
  1050.             ELSE
  1051.               o.GetStdOpts();
  1052.             END;
  1053.             err:=ParseRIFF(anchor,multi);
  1054.             IF err#0 THEN y.SETREG(0,d.PrintFault(err,NIL)); END;
  1055.           END;
  1056.           d.MatchEnd(anchor^);
  1057.         END;
  1058.         y.SETREG(0,d.CurrentDir(oldCD));
  1059.         INC(cnt);
  1060.       UNTIL (cnt=wbs.numArgs) OR (err#0);
  1061.       e.FreeVec(anchor);
  1062.     END;
  1063.   END;
  1064. END HandleWBStart;
  1065. (* \\\ ------------------------------------------------------------------------- *)
  1066.  
  1067. (* /// -------------------- "PROCEDURE HandleShellStart()" --------------------- *)
  1068. PROCEDURE HandleShellStart();
  1069.  
  1070. VAR     files: d.ArgStringArray;
  1071.  
  1072. BEGIN
  1073.   files:=o.GetShellOpts(template);
  1074.   IF files#NIL THEN
  1075.     IF ds.DoAllFiles(files,FALSE,ParseRIFF) THEN END;
  1076.   ELSE
  1077.     HandleFileReq();
  1078.   END;
  1079. END HandleShellStart;
  1080. (* \\\ ------------------------------------------------------------------------- *)
  1081.  
  1082. BEGIN
  1083. (* /// "$IF BETA" *)
  1084.   expire:=d.Date(expireDate,0,0);
  1085.   d.DateStamp(now);
  1086.   IF d.CompareDates(expire,now)>0 THEN
  1087.     d.PrintF("This beta has expired! Please contact me to get a more recent one\n");
  1088.     HALT(0);
  1089.   END;
  1090. (* \\\ $END *)
  1091.   io.noOdd:=TRUE;
  1092.   cu.CheckVersions(version);
  1093.   IF ol.wbStarted THEN
  1094.     HandleWBStart();
  1095.   ELSE
  1096.     HandleShellStart();
  1097.   END;
  1098. (* /// "$IF RUNDEBUG" *)
  1099.   IF o.debug THEN d.PrintF("normal exit\n"); END;
  1100. (* \\\ $END *)
  1101. CLOSE
  1102.   IF fileReq#NIL THEN asl.FreeAslRequest(fileReq); END;
  1103. END CyberAVI.
  1104.